package com.codeying.servlet.rentorder;
import com.codeying.entity.*;
import com.codeying.servlet.AbsServlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.List;
import com.codeying.utils.*;
import com.codeying.utils.component.*;
/**
 * 编辑页面租车订单
 */
@WebServlet("/rentorder/edit")
public class EditRentorderServlet  extends AbsServlet {

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        LoginUser loginUser = MyUtils.getUser(req);
        req.setCharacterEncoding("utf-8");
        String id = req.getParameter("id");
        Rentorder rentorder = rentorderService.getBy("id",id);

        List<User> useridFrnList = userService.list(new QueryMap()  );
        req.setAttribute("useridFrnList",useridFrnList );
        List<Car> cidFrnList = carService.list(new QueryMap()  );
        req.setAttribute("cidFrnList",cidFrnList );
        if(rentorder==null){
            rentorder = new Rentorder();
            //TODO 可接受其他参数 ：req.getParameter("XX")
            String cid = req.getParameter("cid");
            rentorder.setCid(Integer.parseInt(cid));
        }
        req.setAttribute("item",rentorder );
        req.getRequestDispatcher("/pages/rentorder-edit.jsp").forward(req,resp);

    }
}

